package com.twu.biblioteca.domain;


import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sagar
 * Date: 24/9/13
 * Time: 9:45 PM
 * To change this template use File | Settings | File Templates.
 */
public class Library {
    List<Book> books=new ArrayList<Book>();
    ArrayList<Movie> movies=new ArrayList<Movie>();

    public Library(List<Book> books,ArrayList<Movie> movies){
     this.books=books;
     this.movies=movies;

    }
    public ArrayList<Displayable> getAllBooks(){
        return new ArrayList<Displayable>(books);
    }
    public ArrayList<Displayable> getAllMovies(){
        return new ArrayList<Displayable>(movies);
    }


    private Book findById(int id){

        for(Book book :books){
            if(book.getId()==id)
                return book;
        }
        return Book.NON_EXISTENT_BOOK;
    }

    public boolean issueBook(int bookId,User user)  {
       return findById(bookId).issueCopy(user);
    }

}
